<form id="dataDictEditForm" role="form" method="post" action="$!basePath/system/datadict/edit/do">
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h4 class="modal-title">修改数据字典</h4>
</div>
<div class="modal-body">
	<input type="hidden" name="id" value="$!dd.id"/>
	<div class="row">
    	<div class="col-xs-12">
			<div class="form-group">
				<label for="name">分类</label>
			    <div class="input-group">
					<input type="text" name="category" class="form-control" placeholder="字典分类" value="$!dd.category" autofocus/>
					<div class="input-group-btn">
						<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
							选择 <span class="caret"></span>
						</button>
						<ul id="categoryList" class="dropdown-menu pull-right">
							#foreach($!obj in $!list)
							<li onclick="setCategory(this)"><a href="javascript:;">$!obj.category</a></li>
							#end
						</ul>
					</div>
				</div>
			</div>
		</div>
 	</div>
	<div class="row">
		 <div class="col-xs-12">
		   <div class="form-group">
		       <label for="name">名称</label>
		       <input type="text" name="remarks" class="form-control" value="$!dd.remarks"/>
		   </div>
         </div>
     </div>
     <div class="row">
         <div class="col-xs-12">
		   <div class="form-group">
		       <label for="name">Key</label>
		       <input type="text" name="name" class="form-control" autofocus value="$!dd.name"/>
		   </div>
		  </div>
	</div>
</div>
<div class="modal-footer">
    <button id="ok" type="submit" class="btn btn-primary" data-loading-text="正在保存...">确  定</button>
    <button type="button" class="btn btn-default" data-dismiss="modal">取  消</button>
</div>
</form>
<script type="text/javascript">
$(function(){
	ns.requireJS("/framework/js/form/form.js");
	$("#dataDictEditForm").ajaxForm({
		beforeSubmit:function(arr, $form, options){
			$form.find("#ok").button("loading");
		},
		success : function(data, statusText, xhr, $form) {
			if(data.success == true){
				ns.tip.toast.success("字典修改成功！");
				var dialog = ns.view.Dialog.getCur($form);
				dialog.isEdited = true;
				dialog.close();
			}else{
				ns.tip.toast.error(data.message);
			}
            $form.find("#ok").button("reset");
       	}
	});
});
function setCategory(obj) {
	obj = $(obj);
	obj.parent().parent().prev().val(obj.find("a").text());
}
</script>